﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DarkCRM.Helpers;
using System.Data;

namespace DarkCRM.Models
{
    public class CustomFollowup
    {
        public int FollowupID { get; set; }
        public int CustomID { get; set; }
        public int MemberID { get; set; }
        public int CustomFollowupStatus { get; set; }
        public string Note { get; set; }
        public bool Remind { get; set; }
        public bool IsOpportunity { get; set; }
        public bool IsDelete { get; set; }
        public DateTime CreateDate { get; set; }
        public DateTime UpdateDate { get; set; }
        public int UpdateBy { get; set; }
        public CustomFollowup()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }

        private bool Create()
        {
            IDictionary<string, object> par = new Dictionary<string, object>();
            par.Add("CustomID", this.CustomID);
            par.Add("MemberID", this.MemberID);
            par.Add("CustomFollowupStatus", this.CustomFollowupStatus);
            par.Add("Note", this.Note ?? "");
            par.Add("Remind", this.Remind);
            par.Add("IsOpportunity", this.IsOpportunity);

            int i = SqlHelper.ExecuteNonQuery("CreateCustomFollowup", par);
            return i > 0;
        }


        /// <summary>
        /// 创建跟进信息
        /// </summary>
        /// <param name="custom"></param>
        /// <returns></returns>
        [DarkAjax.Utility.jQueryInvokeMethod(Url = "handlers/AjaxController.ashx", Method = "post", DataType = "json", Async = true)]
        public static ResultMessage Create(CustomFollowup custom)
        {           
            return new ResultMessage() { ErrorCode = 0, Lable = "success", Value = custom.Create(), Data = custom };
        }
    }
}